#ifndef glUtils_h__
#define glUtils_h__



#ifndef  SAFE_DELETE
#define  SAFE_DELETE(p) {if(p){delete p;p=NULL;};}
#endif

#ifndef SAFE_DELETE_ARRAY
#define SAFE_DELETE_ARRAY(a) {if(a){delete[] a;a=NULL;}}
#endif

#ifndef SAFE_RELEASE
#define SAFE_RELEASE(p) {if(p){(p)->decRef();p=NULL;}}
#endif

#ifndef ARRAY_SIZE
#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
#endif

/** CC_PROPERTY_READONLY is used to declare a protected variable.
 We can use getter to read the variable.
 @param varType : the type of variable.
 @param varName : variable name.
 @param funName : "get + funName" is the name of the getter.
 @warning : The getter is a public virtual function, you should rewrite it first.
 The variables and methods declared after CC_PROPERTY_READONLY are all public.
 If you need protected or private, please declare.
 */
#define GetProperty(funName,varType, varName)\
protected: varType varName;\
public: varType get##funName(void)const { return varName; }

/** CC_PROPERTY is used to declare a protected variable.
 We can use getter to read the variable, and use the setter to change the variable.
 @param varType : the type of variable.
 @param varName : variable name.
 @param funName : "get + funName" is the name of the getter.
 "set + funName" is the name of the setter.
 @warning : The getter and setter are public virtual functions, you should rewrite them first.
 The variables and methods declared after CC_PROPERTY are all public.
 If you need protected or private, please declare.
 */
#define SetGetProperty(funName,varType, varName)\
protected: varType varName;\
public: varType get##funName(void){return varName;};\
public: void set##funName(varType var){varName = var;};


#endif // glUtils_h__